export default function() {
  var docEl = document.documentElement
  var appWrapper = docEl.getElementsByClassName('app-wrapper')// 获取页面右侧盒子的高度
  var headerBox = docEl.getElementsByClassName('headerBox')// 获取页面右侧盒子的高度
  var contentBoxCon = docEl.getElementsByClassName('contentBoxCon')// 获取页面内容围最外围盒子的高度
  var contentBox = docEl.getElementsByClassName('contentBox')// 获取页面内容围最外围盒子的高度
  var bottomFooterBox = docEl.getElementsByClassName('bottomFooterBox')// 获取页面底部@copy盒子的高度
  var contentBoxRight = docEl.getElementsByClassName('contentBoxRight')// 获取页面右侧盒子的高度
  var contentBoxRightTitle = docEl.getElementsByClassName('contentBoxRightTitle')// 获取导航占用的高度
  var listContentBox = docEl.getElementsByClassName('listContentBox')// 获取列表页面的高度
  // var searchBox = docEl.getElementsByClassName('searchBox')// 获取查询条件的外围盒子的高度
  // var listBox = docEl.getElementsByClassName('listBox')// 获取列表页面的列表与操作按钮的外围盒子的高度
  // var listBoxbtn = docEl.getElementsByClassName('listBoxbtn')// 获取列表页面操作按钮的高度
  // var listBoxTable = docEl.getElementsByClassName('listBoxTable')// 获取列表高度
  // var pagination = docEl.getElementsByClassName('pagination-container')// 获取列表页面操作按钮的高度
  var elInput = docEl.getElementsByClassName('el-input')// 获取页面中的输入框 显示输入字数统计时左侧留的内边距
  var elTextarea = docEl.getElementsByClassName('el-textarea')// 获取查询条件的高度

  var elTableFixed = docEl.getElementsByClassName('el-table__fixed-right')// 表单列表浮动样式
  const headerBoxH = headerBox.length > 0 ? headerBox[0].clientHeight : 0
  const bottomFooterBoxH = bottomFooterBox.length > 0 ? bottomFooterBox[0].clientHeight : 0
  const contentBoxRightH = contentBoxRight.length > 0 ? contentBoxRight[0].clientHeight : 0
  if (contentBox.length > 0) {
    for (let a = 0; a < contentBox.length; a++) {
      if (contentBox[a].classList.value.indexOf('UDLayoutBox') !== -1) {
        // 针对上下布局的高度计算
        docEl.getElementsByClassName('contentBoxCon')[0].style.minHeight = appWrapper[0].clientHeight - headerBoxH - bottomFooterBoxH + 'px'
        docEl.getElementsByClassName('contentBoxCon')[0].style.height = contentBox[a].clientHeight + 'px'
        docEl.getElementsByClassName('bottomFooterBox')[0].style.marginTop = bottomFooterBox.length > 0 ? 18 + 'px' : 0 + 'px'
      } else {
        docEl.getElementsByClassName('contentBoxCon')[0].style.height = appWrapper[0].clientHeight - headerBoxH + 'px'
        const contentBoxRightTitleH = contentBoxRightTitle.length > 0 ? contentBoxRightTitle[0].clientHeight : 0
        docEl.getElementsByClassName('app-main')[0].style.height = contentBoxRightH - contentBoxRightTitleH + 'px'// 给业务页面的最外围的盒子高度定值
      }
    }
  }
  //

  // if (contentBoxCon.length > 0) {
  //   const contentBoxRightTitleH = contentBoxRightTitle.length > 0 ? contentBoxRightTitle[0].clientHeight : 0
  //   docEl.getElementsByClassName('app-main')[0].style.height = contentBoxRightH - contentBoxRightTitleH + 'px'// 给业务页面的最外围的盒子高度定值
  // }

  // 列表的右侧操作按钮浮动后的计算
  if (elTableFixed.length > 0) {
    for (var f = 0; f < elTableFixed.length; f++) {
      elTableFixed[f].style.height = elTableFixed[f].style.height - 1 + 'px'
    }
  }

  // 列表页中的高度计算
  if (listContentBox.length > 0) {
    for (var lcb = 0; lcb < listContentBox.length; lcb++) {
      const listContentBoxH = listContentBox[lcb].clientHeight
      const listBoxLcb = listContentBox[lcb].getElementsByClassName('listBox')
      const listFormBoxLcb = listContentBox[lcb].getElementsByClassName('listFormBox')
      const listBoxTableLcb = listContentBox[lcb].getElementsByClassName('listBoxTable')
      const paginationLcb = listContentBox[lcb].getElementsByClassName('pagination-container')
      const searchBoxLcb = listContentBox[lcb].getElementsByClassName('searchBox')
      const listBoxbtnLcb = listContentBox[lcb].getElementsByClassName('listBoxbtn')
      var formBtnBoxLcb = listContentBox[lcb].getElementsByClassName('formBtn')
      const paginationH = paginationLcb.length > 0 ? paginationLcb[lcb].clientHeight + 16 : 0// 分页的高度
      const listBoxbtnLcbH = listBoxbtnLcb.length > 0 ? listBoxbtnLcb[lcb].clientHeight + 16 : 0// 列表页中的操作按钮的高度
      const searchBoxLcbH = searchBoxLcb.length > 0 ? searchBoxLcb[lcb].clientHeight + 16 : 0// 查询条件的高度
      const formBtnBoxLcbH = formBtnBoxLcb.length > 0 ? formBtnBoxLcb[lcb].clientHeight + 16 : 0// 查询条件的高度
      // listBox的高度值
      if (listBoxLcb && listBoxLcb.length > 0) {
        listBoxLcb[lcb].style.height = listContentBoxH - searchBoxLcbH - 16 + 'px'
      }
      // listBoxTable 的高度值
      if (listBoxTableLcb && listBoxTableLcb.length > 0) {
        const listBoxLcbH = listBoxLcb.length > 0 ? listBoxLcb[lcb].clientHeight : 0
        if (listContentBox[lcb].className.includes('dialogListContentBox') == false){
          //   // 弹窗列表高度计算
          //   listBoxTableLcb[lcb].style.height = listBoxLcbH - paginationH - listBoxbtnLcbH - formBtnBoxLcbH - 32 + 'px'
          // } else {
          // 默认列表高度计算
          listBoxTableLcb[lcb].style.height = listBoxLcbH - paginationH - listBoxbtnLcbH - formBtnBoxLcbH - 16 + 'px'
        }
      }
    }
  }
  // // 弹窗的计算
  var elDialogW = docEl.getElementsByClassName('el-dialog__wrapper')// 获取弹窗
  // var elDialog = docEl.getElementsByClassName('el-dialog')// 获取弹窗
  if (elDialogW.length > 0) {
    for (var e = 0; e < elDialogW.length; e++) {
      if (elDialogW[e].style.display !== 'none') {
        const elDialogWE = elDialogW[e]
        const elDialogWEH = elDialogWE.clientHeight
        const elDialogChild = elDialogWE.getElementsByClassName('el-dialog')[0]
        const elDialogChildT = elDialogChild.offsetTop * 2
        const elDialogHeader = elDialogWE.getElementsByClassName('el-dialog__header')[0]
        const elDialogFooter = elDialogWE.getElementsByClassName('el-dialog__footer')[0]
        const headerBoxH = elDialogHeader ? elDialogHeader.clientHeight : 0// 头部
        const footeBoxH = elDialogFooter ? elDialogFooter.clientHeight : 0// 底部
        if (elDialogChild) {
          elDialogChild.getElementsByClassName('el-dialog__body')[0].style.maxHeight = elDialogWEH - headerBoxH - footeBoxH - elDialogChildT + 'px'
        }
      }
    }
  }

  // 强行对输入框的左侧家加内边距
  for (var i = 0; i < elInput.length; i++) {
    const childrenList = elInput[i].children
    for (var j = 0; j < childrenList.length; j++) {
      const childrenListSpan = childrenList[j].getElementsByTagName('span')
      if (childrenListSpan.length > 0) {
        for (var a = 0; a < childrenListSpan.length; a++) {
          const childrenListSpanCount = childrenListSpan[a].getElementsByClassName('el-input__count')
          if (childrenListSpanCount.length > 0) {
            elInput[i].getElementsByClassName('el-input__inner')[0].style.paddingRight = (childrenList[j].clientWidth - 10) * 2 + 'px'
          }
        }
      }
    }
  }
  // 强制对textarea的底部加内边距
  for (var b = 0; b < elTextarea.length; b++) {
    const childrenList = elTextarea[b].children
    if (childrenList.length > 1) {
      elTextarea[b].style.paddingBottom = '2.2rem'
    }
  }
}
